package com.sdtele.tta.operation;

import java.util.HashMap;
import java.util.Map;

import com.sdtele.tta.dac.Dac;
import com.sdtele.tta.models.JsonRequest;
import com.sdtele.tta.models.JsonResponse;
import com.sdtele.tta.models.Team;
import com.sdtele.tta.models.User;

/**
 * 操作类实现：GetUser(json.operation=getUser)
 * 
 * @author XCream 说明 8.31 9.01
 */
public class OperationGetUserById extends Operation {

	@Override
	public JsonResponse handle(JsonRequest jsonRequest) {
		JsonResponse jres = new JsonResponse();
		User curUser = (User) request.getSession().getAttribute("user");

		if (curUser != null) {
			long userId=jsonRequest.getJsonObject().get("userId").getAsLong();
			Map<String,Object> uMap=new HashMap<String,Object>();
			User user=Dac.getInstance().getUser(userId);
			Team team=Dac.getInstance().getTeam(user.getTeamId());
			uMap.put("user", user);
			uMap.put("team", team);
			jres.setStatus(0);			
			jres.setEntity(uMap);			
		} else {
			jres.setStatus(1);
			jres.setMessage("用户未登录");
		}
		return jres;
	}

}
